# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libdiscid
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.6.2
pkgrel=1
pkgdesc="A Library for creating MusicBrainz DiscIDs (mingw-w64)"
arch=('any')
url="https://musicbrainz.org/doc/libdiscid"
license=('LGPL')
source=("http://ftp.musicbrainz.org/pub/musicbrainz/libdiscid/${_realname}-${pkgver}.tar.gz"
        "libdiscid-0.6.2-include-location.patch")
sha256sums=('f9e443ac4c0dd4819c2841fcc82169a46fb9a626352cdb9c7f65dd3624cd31b9'
            '227e1539e175da6323b1bfd92ac783cee4dbd5d940f97af77a1e67f25bfaa2e8')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/libdiscid-0.6.2-include-location.patch"
  autoreconf -fiv
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${CARCH}
  make check
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
